bitkeeper revision 1.819 (405ff597IZG6ZJZ_KUXF4rm3sEo57A)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 23 Mar 2004 08:30:15 +0000 (08:30 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 23 Mar 2004 08:30:15 +0000 (08:30 +0000)
console_client.py, xencons, Makefile, Console-HOWTO.txt:
  Console and controller modifications.
xend:
  new file
xendomains:
  Rename: tools/examples/xendomains -> tools/examples/init.d/xendomains

.rootkeys
docs/Console-HOWTO.txt
tools/examples/Makefile
tools/examples/init.d/xend [new file with mode: 0755]
tools/examples/init.d/xendomains [new file with mode: 0755]
tools/examples/xendomains [deleted file]
tools/misc/xencons
tools/xenctl/lib/console_client.py

index 682628e2633a2867a00f2f3637a88684156bf8c1..aeda8c823aa985a5f0ba768df8cd745afed3a0e3 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
 401d7e16GS8YesM1zateRbaOoI6YLQ tools/examples/defaults
 401d7e16NoWaBGC1RXbBcqAOr5Uaag tools/examples/democd
+405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend
+40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains
 40278d91ZjLhxdjjrGe8HEdwHLj5xQ tools/examples/netbsd
 401d7e16NpnVrFSsR7lKKKfTwCYvWA tools/examples/xc_dom_control.py
 401d7e16RJj-lbtsVEjua6HYAIiKiA tools/examples/xc_dom_create.py
 403b7cf7J7FsSSoEPGhx6gXR4pIdZg tools/examples/xc_physinfo.py
 401d7e16X4iojyKopo_j63AyzYZd2A tools/examples/xc_vd_tool.py
-40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/xendomains
 3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
 3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile
 3f6dc140C8tAeBfroAF24VrmCS4v_w tools/misc/miniterm/README
index 5d8d5ee3e2c44b6ab9a1c68acc2492bbad80fea8..7844d97f77b6a4b9f4643219323096e09f9d7a39 100644 (file)
@@ -56,6 +56,14 @@ Virtual console for other domains
  rc.local):
   # /usr/sbin/xend start
 
+ Alternatively, Redhat- and LSB-compatible Linux installations can use
+ the provided init.d script. To integrate startup and shutdown of xend
+ in such a system, you will need to run a few configuration commands:
+  # chkconfig --add xend
+  # chkconfig --level 35 on
+  # chkconfig --level 01246 off
+ This will avoid the need to run xend manually from rc.local, for example.
+
  Note that, when a domain is created using xc_dom_create.py, xend MUST
  be running. If everything is set up correctly then xc_dom_create will
  print the local TCP port to which you should connect to perform
index 570e291f6630b0b7a8bad3eae3b06e7460e1062b..1f57924338bf5c2bdcd65f9fa9b969a08547b518 100644 (file)
@@ -1,7 +1,7 @@
 
 INSTALL  = $(wildcard *.py)
 ETC     = defaults democd netbsd
-INITD    = xendomains
+INITD    = init.d/xendomains init.d/xend
 
 all: 
 
diff --git a/tools/examples/init.d/xend b/tools/examples/init.d/xend
new file mode 100755 (executable)
index 0000000..bf1cc93
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# xend         Script to start and stop the Xen control daemon.
+#
+# Author:       Keir Fraser <keir.fraser@cl.cam.ac.uk>
+#
+# chkconfig: 2345 99 00
+# description: Starts and stops the Xen control daemon.
+
+. /etc/init.d/functions
+
+case "$1" in
+  start)
+       xend start
+       exit $?
+       ;;
+  stop)
+       xend stop
+       exit $?
+       ;;
+  status)
+       ;;
+  restart|reload)
+       ;;
+  *)
+       # do not advertise unreasonable commands that there is no reason
+       # to use with this device
+       echo $"Usage: $0 {start|stop|status|restart|reload}"
+       exit 1
+esac
+
+exit 0
+
diff --git a/tools/examples/init.d/xendomains b/tools/examples/init.d/xendomains
new file mode 100755 (executable)
index 0000000..fa96ff8
--- /dev/null
@@ -0,0 +1,160 @@
+#!/bin/sh
+#
+# /etc/init.d/xendomains
+# Start / stop domains automatically when domain 0 boots / shuts down.
+#
+# chkconfig: 345 99 00
+# description: Start / stop Xen domains.
+#
+# This script offers fairly basic functionality.  It should work on Redhat
+# but also on LSB-compliant SuSE releases and on Debian with the LSB package
+# installed.  (LSB is the Linux Standard Base)
+#
+# Based on the example in the "Designing High Quality Integrated Linux
+# Applications HOWTO" by Avi Alkalay
+# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
+#
+
+RETVAL=0
+
+INITD=/etc/init.d/
+
+if [ -e /lib/lsb ]; then
+    # assume an LSB-compliant distro (Debian with LSB package,
+    # recent-enough SuSE, others...)
+
+    . /lib/lsb/init-functions # source LSB standard functions
+
+    on_fn_exit()
+    {
+       if [ $RETVAL -eq 0 ]; then
+           log_success_msg
+       else
+           log_failure_msg
+       fi
+    }
+else
+    # assume a Redhat-like distro
+    . $INITD/functions # source Redhat functions
+
+    on_fn_exit()
+    {
+       if [ $RETVAL -eq 0 ]; then
+           success
+       else
+           failure
+       fi
+       
+       echo
+    }
+fi
+
+
+
+start() {
+    if [ -f /var/lock/subsys/xendomains ]; then return; fi
+
+    echo -n $"Starting auto Xen domains:"
+
+    # we expect config scripts for auto starting domains to be in
+    # /etc/xc/auto/ - they could just be symlinks to files elsewhere
+    if [ -d /etc/xc/auto ] &&
+           [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
+       
+       # create all domains with config files in /etc/xc/auto
+       for dom in /etc/xc/auto/*; do
+           xc_dom_create.py -q -f $dom
+           if [ $? -ne 0 ]; then
+               RETVAL=$?
+           fi
+       done
+
+       touch /var/lock/subsys/xendomains
+    fi
+
+    on_fn_exit
+}
+
+stop()
+{
+    # NB. this shuts down ALL Xen domains (politely), not just the ones in
+    # /etc/xc/auto/*
+    # This is because it's easier to do ;-) but arguably if this script is run
+    # on system shutdown then it's also the right thing to do.
+    
+    echo -n $"Shutting down all Xen domains:"
+
+    if [ -d /var/run/xendomains ] &&
+           [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
+       
+       cd /var/run/xendomains/
+
+       for pid in *; do
+          
+           kill -s SIGTERM $(cat $pid)
+
+       done
+
+    fi
+
+    sleep 3 # avoid races
+
+    xc_dom_control.py shutdown all -w # shut down all domains, politely and wait
+                                      # for all to exit
+    
+    RETVAL=$?
+
+    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xendomains
+
+    on_fn_exit
+}
+
+# This does NOT necessarily restart all running domains: instead it
+# stops all running domains and then boots all the domains specified in
+# /etc/xc/auto.  If other domains have been started manually then they will
+# not get restarted.
+# Commented out to avoid confusion!
+#
+#restart()
+#{
+#    stop
+#    start
+#}
+
+# same as restart for now - commented out to avoid confusion
+#reload()
+#{
+#    restart
+#}
+
+
+case "$1" in
+    start)
+       start
+       ;;
+
+    stop)
+       stop
+       ;;
+
+# The following are commented out to disable them by default to avoid confusion
+# - see the notes above
+#
+#    restart)
+#      restart
+#      ;;
+#
+#    reload)
+#      reload
+#      ;;
+
+    status)
+       xc_dom_control.py list
+       ;;
+
+    *)
+       echo $"Usage: $0 {start|stop|status}"
+       ;;
+esac
+
+exit $RETVAL
diff --git a/tools/examples/xendomains b/tools/examples/xendomains
deleted file mode 100755 (executable)
index fa96ff8..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/bin/sh
-#
-# /etc/init.d/xendomains
-# Start / stop domains automatically when domain 0 boots / shuts down.
-#
-# chkconfig: 345 99 00
-# description: Start / stop Xen domains.
-#
-# This script offers fairly basic functionality.  It should work on Redhat
-# but also on LSB-compliant SuSE releases and on Debian with the LSB package
-# installed.  (LSB is the Linux Standard Base)
-#
-# Based on the example in the "Designing High Quality Integrated Linux
-# Applications HOWTO" by Avi Alkalay
-# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
-#
-
-RETVAL=0
-
-INITD=/etc/init.d/
-
-if [ -e /lib/lsb ]; then
-    # assume an LSB-compliant distro (Debian with LSB package,
-    # recent-enough SuSE, others...)
-
-    . /lib/lsb/init-functions # source LSB standard functions
-
-    on_fn_exit()
-    {
-       if [ $RETVAL -eq 0 ]; then
-           log_success_msg
-       else
-           log_failure_msg
-       fi
-    }
-else
-    # assume a Redhat-like distro
-    . $INITD/functions # source Redhat functions
-
-    on_fn_exit()
-    {
-       if [ $RETVAL -eq 0 ]; then
-           success
-       else
-           failure
-       fi
-       
-       echo
-    }
-fi
-
-
-
-start() {
-    if [ -f /var/lock/subsys/xendomains ]; then return; fi
-
-    echo -n $"Starting auto Xen domains:"
-
-    # we expect config scripts for auto starting domains to be in
-    # /etc/xc/auto/ - they could just be symlinks to files elsewhere
-    if [ -d /etc/xc/auto ] &&
-           [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
-       
-       # create all domains with config files in /etc/xc/auto
-       for dom in /etc/xc/auto/*; do
-           xc_dom_create.py -q -f $dom
-           if [ $? -ne 0 ]; then
-               RETVAL=$?
-           fi
-       done
-
-       touch /var/lock/subsys/xendomains
-    fi
-
-    on_fn_exit
-}
-
-stop()
-{
-    # NB. this shuts down ALL Xen domains (politely), not just the ones in
-    # /etc/xc/auto/*
-    # This is because it's easier to do ;-) but arguably if this script is run
-    # on system shutdown then it's also the right thing to do.
-    
-    echo -n $"Shutting down all Xen domains:"
-
-    if [ -d /var/run/xendomains ] &&
-           [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
-       
-       cd /var/run/xendomains/
-
-       for pid in *; do
-          
-           kill -s SIGTERM $(cat $pid)
-
-       done
-
-    fi
-
-    sleep 3 # avoid races
-
-    xc_dom_control.py shutdown all -w # shut down all domains, politely and wait
-                                      # for all to exit
-    
-    RETVAL=$?
-
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xendomains
-
-    on_fn_exit
-}
-
-# This does NOT necessarily restart all running domains: instead it
-# stops all running domains and then boots all the domains specified in
-# /etc/xc/auto.  If other domains have been started manually then they will
-# not get restarted.
-# Commented out to avoid confusion!
-#
-#restart()
-#{
-#    stop
-#    start
-#}
-
-# same as restart for now - commented out to avoid confusion
-#reload()
-#{
-#    restart
-#}
-
-
-case "$1" in
-    start)
-       start
-       ;;
-
-    stop)
-       stop
-       ;;
-
-# The following are commented out to disable them by default to avoid confusion
-# - see the notes above
-#
-#    restart)
-#      restart
-#      ;;
-#
-#    reload)
-#      reload
-#      ;;
-
-    status)
-       xc_dom_control.py list
-       ;;
-
-    *)
-       echo $"Usage: $0 {start|stop|status}"
-       ;;
-esac
-
-exit $RETVAL
index b826c89dee7571a1cc6570d2a43001593af3ac6d..31c87a1ed79fba2c04cfb620f92b10a3730e45d1 100755 (executable)
@@ -26,7 +26,7 @@ def __recv_from_sock(sock):
     stop = False
     while not stop:
         try:
-            data = sock.recv(1)
+            data = sock.recv(1024)
             os.write(1, data)
         except socket.error, error:
             if error[0] != errno.EINTR:
@@ -35,7 +35,7 @@ def __recv_from_sock(sock):
 
 def __send_to_sock(sock):
     while 1:
-        data = os.read(0,1)
+        data = os.read(0,1024)
         if ord(data[0]) == ord(']')-64:
             break
         try:
index b826c89dee7571a1cc6570d2a43001593af3ac6d..31c87a1ed79fba2c04cfb620f92b10a3730e45d1 100644 (file)
@@ -26,7 +26,7 @@ def __recv_from_sock(sock):
     stop = False
     while not stop:
         try:
-            data = sock.recv(1)
+            data = sock.recv(1024)
             os.write(1, data)
         except socket.error, error:
             if error[0] != errno.EINTR:
@@ -35,7 +35,7 @@ def __recv_from_sock(sock):
 
 def __send_to_sock(sock):
     while 1:
-        data = os.read(0,1)
+        data = os.read(0,1024)
         if ord(data[0]) == ord(']')-64:
             break
         try: